import React, {Component} from 'react';
import {Row, Col, Spin} from 'antd';
import "../css/outPutManage.css";
import app from '../AppMethod';
import {orderList} from "../value";
import moment from 'moment';

class Delivery extends Component {
    constructor(props) {
        super(props);
        this.state = {
            loading: false,
            pendingOrder: [],
            urgentPendingOrder: [],
            overtimePendingOrder: [],
            receiptOrder: [],
            urgentReceiptOrder: [],
            overtimeReceiptOrder: [],
            configureOrder: [],
            urgentConfigureOrder: [],
            overtimeConfigureOrder: [],
            checkOrder: [],
            urgentCheckOrder: [],
            overtimeCheckOrder: [],
            editOrder: [],
            urgentEditOrder: [],
            overtimeEditOrder: [],
            sendOrder: [],
            urgentSendOrder: [],
            overtimeSendOrder: [],
            currentPage: 1
        }
    };

    render() {
        return (
            <div style={{height: '100%'}}>
                <Row onDoubleClick={() => this.handleDoubleClick()} style={{height: '100%'}}>
                    <Spin spinning={this.state.loading} wrapperClassName="deliverySpinContainer">
                        {
                            this.state.currentPage == 1 ?
                                <Row style={{height: '100%'}}>
                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            待接单
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={5} className="outPutHeaderCol">下单时间</Col>
                                            <Col span={5} className="outPutHeaderCol">订单号</Col>
                                            <Col span={6} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={3} className="outPutHeaderCol">负责人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentPendingOrder.length > 0 ?
                                                    <span>
                                                    <Row className="outPutTime outPutTime1">
                                                加急订单
                                                    </Row>
                                                    <div>
                                                        {
                                                            this.state.urgentPendingOrder.map((item, index) => {
                                                                return (
                                                                    <PendingOrderItem data={item} key={index} type="0"/>
                                                                )
                                                            })
                                                        }
                                                    </div>
                                                </span> : ''
                                            }
                                            {
                                                this.state.overtimePendingOrder.length > 0 ?
                                                    <span>
                                                    <Row className="outPutTime outPutTime2">
                                                        超时订单
                                                    </Row>
                                                    <div>
                                                        {
                                                            this.state.overtimePendingOrder.map((item, index) => {
                                                                return (
                                                                    <PendingOrderItem data={item} key={index} type="0"/>
                                                                )
                                                            })
                                                        }
                                                    </div>
                                                </span> : ''
                                            }
                                            {
                                                this.state.pendingOrder.length <= 0 && this.state.urgentPendingOrder.length <= 0 && this.state.urgentPendingOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.pendingOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.pendingOrder.map((item, index) => {
                                                            return (
                                                                <PendingOrderNormal time={item.output_order_time}
                                                                                    data={item.data} key={index}
                                                                                    type="0"/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>

                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            已接单
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={5} className="outPutHeaderCol">接单时间</Col>
                                            <Col span={5} className="outPutHeaderCol">订单号</Col>
                                            <Col span={6} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={3} className="outPutHeaderCol">接单人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentReceiptOrder.length > 0 ? <span>
                                <Row className="outPutTime outPutTime1">
                                    加急订单
                                </Row>
                                <div>
                                {
                                    this.state.urgentReceiptOrder.map((item, index) => {
                                        return (
                                            <PendingOrderItem data={item} key={index} type="1"/>
                                        )
                                    })
                                }
                                </div>
                                </span> : ''
                                            }
                                            {
                                                this.state.overtimeReceiptOrder.length > 0 ?
                                                    <span>
                                    <Row className="outPutTime outPutTime2">
                                        超时订单
                                    </Row>
                                    <div>
                                    {

                                        this.state.overtimeReceiptOrder.map((item, index) => {
                                            return (
                                                <PendingOrderItem data={item} key={index} type="1"/>
                                            )
                                        })
                                    }
                                    </div>
                                    </span> : ''
                                            }
                                            {
                                                this.state.receiptOrder.length <= 0 && this.state.overtimeReceiptOrder.length <= 0 && this.state.urgentReceiptOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.receiptOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.receiptOrder.map((item, index) => {
                                                            return (
                                                                <PendingOrderNormal time={item.output_take_time}
                                                                                    data={item.data} key={index}
                                                                                    type="1"/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>
                                </Row> : ''
                        }
                        {
                            this.state.currentPage == 2 ?
                                <Row style={{height: '100%'}}>
                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            配货中
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={5} className="outPutHeaderCol">配货开始时间</Col>
                                            <Col span={5} className="outPutHeaderCol">订单号</Col>
                                            <Col span={6} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={3} className="outPutHeaderCol">配货人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentConfigureOrder.length > 0 ? <span>
                                <Row className="outPutTime outPutTime1">
                                    加急订单
                                </Row>
                                <div>
                                {
                                    this.state.urgentConfigureOrder.map((item, index) => {
                                        return (
                                            <PendingOrderItem data={item} key={index} type="2"/>
                                        )
                                    })
                                }
                                </div>
                                </span> : ''
                                            }
                                            {
                                                this.state.overtimeConfigureOrder.length > 0 ?
                                                    <span>
                                    <Row className="outPutTime outPutTime2">
                                        超时订单
                                    </Row>
                                    <div>
                                    {

                                        this.state.overtimeConfigureOrder.map((item, index) => {
                                            return (
                                                <PendingOrderItem data={item} key={index} type="2"/>
                                            )
                                        })
                                    }
                                    </div>
                                    </span> : ''
                                            }
                                            {
                                                this.state.configureOrder.length <= 0 && this.state.overtimeConfigureOrder.length <= 0 && this.state.urgentConfigureOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.configureOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.configureOrder.map((item, index) => {
                                                            return (
                                                                <PendingOrderNormal time={item.output_pick_time}
                                                                                    data={item.data} key={index}
                                                                                    type="2"/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>
                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            待对货
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={5} className="outPutHeaderCol">配货结束时间</Col>
                                            <Col span={5} className="outPutHeaderCol">订单号</Col>
                                            <Col span={6} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={3} className="outPutHeaderCol">配货人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentCheckOrder.length > 0 ? <span>
                                <Row className="outPutTime outPutTime1">
                                    加急订单
                                </Row>
                                <div>
                                {
                                    this.state.urgentCheckOrder.map((item, index) => {
                                        return (
                                            <PendingOrderItem data={item} key={index} type="3"/>
                                        )
                                    })
                                }
                                </div>
                                </span> : ''
                                            }
                                            {
                                                this.state.overtimeCheckOrder.length > 0 ?
                                                    <span>
                                    <Row className="outPutTime outPutTime2">
                                        超时订单
                                    </Row>
                                    <div>
                                    {

                                        this.state.overtimeCheckOrder.map((item, index) => {
                                            return (
                                                <PendingOrderItem data={item} key={index} type="3"/>
                                            )
                                        })
                                    }
                                    </div>
                                    </span> : ''
                                            }
                                            {
                                                this.state.checkOrder.length <= 0 && this.state.overtimeCheckOrder.length <= 0 && this.state.urgentCheckOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.checkOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.checkOrder.map((item, index) => {
                                                            return (
                                                                <PendingOrderNormal time={item.output_pick_end_time}
                                                                                    data={item.data} key={index}
                                                                                    type="3"/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>
                                </Row> : ''
                        }
                        {
                            this.state.currentPage == 3 ?
                                <Row style={{height: '100%'}}>
                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            待改单
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={5} className="outPutHeaderCol">对货结束时间</Col>
                                            <Col span={5} className="outPutHeaderCol">订单号</Col>
                                            <Col span={6} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={3} className="outPutHeaderCol">对货人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentEditOrder.length > 0 ? <span>
                                <Row className="outPutTime outPutTime1">
                                    加急订单
                                </Row>
                                <div>
                                {
                                    this.state.urgentEditOrder.map((item, index) => {
                                        return (
                                            <PendingOrderItem data={item} key={index} type="5"/>
                                        )
                                    })
                                }
                                </div>
                                </span> : ''
                                            }
                                            {
                                                this.state.overtimeEditOrder.length > 0 ?
                                                    <span>
                                    <Row className="outPutTime outPutTime2">
                                        超时订单
                                    </Row>
                                    <div>
                                    {

                                        this.state.overtimeEditOrder.map((item, index) => {
                                            return (
                                                <PendingOrderItem data={item} key={index} type="5"/>
                                            )
                                        })
                                    }
                                    </div>
                                    </span> : ''
                                            }
                                            {
                                                this.state.editOrder.length <= 0 && this.state.urgentEditOrder.length <= 0 && this.state.overtimeEditOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.editOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.editOrder.map((item, index) => {
                                                            return (
                                                                <PendingOrderNormal time={item.output_match_time}
                                                                                    data={item.data} key={index}
                                                                                    type="5"/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>
                                    <Col span={12} className="outPutItem">
                                        <Row className="outPutType">
                                            待配送
                                        </Row>
                                        <Row className="outPutHeader">
                                            <Col span={4} className="outPutHeaderCol">对货结束时间</Col>
                                            <Col span={3} className="outPutHeaderCol">订单号</Col>
                                            <Col span={4} className="outPutHeaderCol">客户名称</Col>
                                            <Col span={2} className="outPutHeaderCol">对货人</Col>
                                            <Col span={2} className="outPutHeaderCol">类型</Col>
                                            <Col span={3} className="outPutHeaderCol">物流类型</Col>
                                            <Col span={2} className="outPutHeaderCol">件数</Col>
                                            <Col span={2} className="outPutHeaderCol">散件数</Col>
                                            <Col span={2} className="outPutHeaderCol">总件数</Col>
                                        </Row>
                                        <div className="outPutContainer">
                                            {
                                                this.state.urgentSendOrder.length > 0 ? <span>
                                <Row className="outPutTime outPutTime1">
                                    加急订单
                                </Row>
                                <div>
                                {
                                    this.state.urgentSendOrder.map((item, index) => {
                                        return (
                                            <SendOrderItem data={item} key={index}/>
                                        )
                                    })
                                }
                                </div>
                                </span> : ''
                                            }
                                            {
                                                this.state.overtimeSendOrder.length > 0 ?
                                                    <span>
                                    <Row className="outPutTime outPutTime2">
                                        超时订单
                                    </Row>
                                    <div>
                                    {

                                        this.state.overtimeSendOrder.map((item, index) => {
                                            return (
                                                <SendOrderItem data={item} key={index} type="4"/>
                                            )
                                        })
                                    }
                                    </div>
                                    </span> : ''
                                            }
                                            {
                                                this.state.sendOrder.length <= 0 && this.state.overtimeSendOrder.length <= 0 && this.state.urgentSendOrder <= 0 ? '' :
                                                    <Row className="outPutTime normal">
                                                        正常
                                                    </Row>
                                            }
                                            <div>
                                                {
                                                    this.state.sendOrder.length <= 0 ?
                                                        <div style={{
                                                            textAlign: 'center',
                                                            lineHeight: '50px',
                                                            height: '50px'
                                                        }}>
                                                            无数据</div> :
                                                        this.state.sendOrder.map((item, index) => {
                                                            return (
                                                                <SendOrderNormal time={item.output_match_time}
                                                                                 data={item.data} key={index}/>
                                                            )
                                                        })
                                                }
                                            </div>
                                        </div>
                                    </Col>
                                </Row> : ''
                        }
                    </Spin>
                </Row>
            </div>
        )
    };

    componentDidMount() {
        this.handleGetOrderData();
        this.timer = setInterval(() => this.handleGetOrderData(), 1000 * 60 * 1);
    };

    componentWillUnmount() {
        clearInterval(this.timer);
        this.setState = (count, callback) => {
            return;
        }
    };

    /**
     * 监听双击切换事件
     */
    handleDoubleClick() {
        let currentPage = this.state.currentPage;
        if (currentPage < 3) {
            currentPage = currentPage + 1;
        } else if (currentPage >= 3) {
            currentPage = 1;
        }
        this.setState({currentPage: currentPage});
    }

    /**
     * 根据不同条件获取出库端订单列表
     */
    handleGetOrderData() {
        let id = this.props.match.params.id;
        //this.setState({loading: true});
        //待接单（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '0'}).then((result) => {
            if (result.code === 1) {
                //console.log(result);
                let data = result.data.dataSet;

                for (let i = 0; i < data.length; i++) {
                    data[i].output_order_time = data[i].output_order_time == null ? '' : moment(data[i].output_order_time).format('YYYY-MM-DD');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_order_time]) {
                        temp.push({
                            output_order_time: item.output_order_time,
                            data: [item]
                        });
                        map[item.output_order_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let dataItem = temp[j];
                            if (dataItem.output_order_time == item.output_order_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({pendingOrder: temp});
            } else {
                this.setState({pendingOrder: []});
            }
        });
        //待接单（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '0'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_order_time = data[i].output_order_time == null ? '' : moment(data[i].output_order_time).format('YYYY-MM-DD');
                }
                this.setState({urgentPendingOrder: data});
            } else {
                this.setState({urgentPendingOrder: []});
            }
        });
        //待接单（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '0'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_order_time = data[i].output_order_time == null ? '' : moment(data[i].output_order_time).format('YYYY-MM-DD');
                }
                this.setState({overtimePendingOrder: data});
            } else {
                this.setState({overtimePendingOrder: []});
            }
        });

        //已接单（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '1'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_take_time = data[i].output_take_time == null ? '' : moment(data[i].output_take_time).format('YYYY-MM-DD HH:mm');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_take_time]) {
                        temp.push({
                            output_take_time: item.output_take_time,
                            data: [item]
                        });
                        map[item.output_take_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let data = temp[j];
                            if (data.output_take_time == item.output_take_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({receiptOrder: temp});
            } else {
                this.setState({receiptOrder: []});
            }
        });
        //已接单（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '1'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_take_time = data[i].output_take_time == null ? '' : moment(data[i].output_take_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({urgentReceiptOrder: data});
            } else {
                this.setState({urgentReceiptOrder: []});
            }
        });
        //已接单（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '1'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_take_time = data[i].output_take_time == null ? '' : moment(data[i].output_take_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({overtimeReceiptOrder: data});
            } else {
                this.setState({overtimeReceiptOrder: []});
            }
        });

        //配货中（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '2'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_time = data[i].output_pick_time == null ? '' : moment(data[i].output_pick_time).format('YYYY-MM-DD HH:mm');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_pick_time]) {
                        temp.push({
                            output_pick_time: item.output_pick_time,
                            data: [item]
                        });
                        map[item.output_pick_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let data = temp[j];
                            if (data.output_pick_time == item.output_pick_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({configureOrder: temp});
            } else {
                this.setState({configureOrder: []});
            }
        });
        //配货中（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '2'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_time = data[i].output_pick_time == null ? '' : moment(data[i].output_pick_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({urgentConfigureOrder: data});
            } else {
                this.setState({urgentConfigureOrder: []});
            }
        });
        //配货中（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '2'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_time = data[i].output_pick_time == null ? '' : moment(data[i].output_pick_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({overtimeConfigureOrder: data});
            } else {
                this.setState({overtimeConfigureOrder: []});
            }
        });

        //待对货（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '3'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_end_time = data[i].output_pick_end_time == null ? '' : moment(data[i].output_pick_end_time).format('YYYY-MM-DD HH:mm');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_pick_end_time]) {
                        temp.push({
                            output_pick_end_time: item.output_pick_end_time,
                            data: [item]
                        });
                        map[item.output_pick_end_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let data = temp[j];
                            if (data.output_pick_end_time == item.output_pick_end_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({checkOrder: temp});
            } else {
                this.setState({checkOrder: []});
            }
        });
        //待对货（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '3'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_end_time = data[i].output_pick_end_time == null ? '' : moment(data[i].output_pick_end_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({urgentCheckOrder: data});
            } else {
                this.setState({urgentCheckOrder: []});
            }
        });
        //待对货（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '3'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_pick_end_time = data[i].output_pick_end_time == null ? '' : moment(data[i].output_pick_end_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({overtimeCheckOrder: data});
            } else {
                this.setState({overtimeCheckOrder: []});
            }
        });

        //待改单（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '5'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH:mm');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_match_time]) {
                        temp.push({
                            output_match_time: item.output_match_time,
                            data: [item]
                        });
                        map[item.output_match_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let data = temp[j];
                            if (data.output_match_time == item.output_match_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({editOrder: temp});
            } else {
                this.setState({editOrder: []});
            }
        });
        //待改单（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '5'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({urgentEditOrder: data});
            } else {
                this.setState({urgentEditOrder: []});
            }
        });
        //待改单（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '5'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH:mm');
                }
                this.setState({overtimeEditOrder: data});
            } else {
                this.setState({overtimeEditOrder: []});
            }
        });
        //待配送（正常）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '2', output_status: '4'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH');
                }
                let map = {};
                let temp = [];
                for (let i = 0; i < data.length; i++) {
                    let item = data[i];
                    if (!map[item.output_match_time]) {
                        temp.push({
                            output_match_time: item.output_match_time,
                            data: [item]
                        });
                        map[item.output_match_time] = item;
                    } else {
                        for (let j = 0; j < temp.length; j++) {
                            let data = temp[j];
                            if (data.output_match_time == item.output_match_time) {
                                temp[j].data.push(item);
                                break;
                            }
                        }
                    }
                }
                this.setState({sendOrder: temp});
            } else {
                this.setState({sendOrder: []});
            }
        });
        //待配送（加急）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '0', output_status: '4'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH');
                }
                this.setState({urgentSendOrder: data});
            } else {
                this.setState({urgentSendOrder: []});
            }
        });
        //待配送（超时）
        app.post(orderList.SHOW_OUTPUTLIST, {stock_id: id, type: '1', output_status: '4'}).then((result) => {
            if (result.code === 1) {
                let data = result.data.dataSet;
                for (let i = 0; i < data.length; i++) {
                    data[i].output_match_time = data[i].output_match_time == null ? '' : moment(data[i].output_match_time).format('YYYY-MM-DD HH');
                }
                this.setState({overtimeSendOrder: data});
            } else {
                this.setState({overtimeSendOrder: []});
            }
        });

    }
};

/**
 * 订单子组件
 */
class PendingOrderItem extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {
        const {
            output_is_change, output_order_time, output_take_time, output_pick_time, output_num, customer_name, output_follow_name, output_take_name, output_pick_name, output_type, output_logistics
            , output_pick_end_time, output_match_time, output_match_name, output_is_back
        } = this.props.data;
        const type = this.props.type;
        return (
            <Row
                className={output_is_back == 1 ? 'outPutTableContainer1' : output_is_change == 1 ? "outPutTableContainer2" : "outPutTableContainer"}>
                <Col span={5}
                     className={output_is_back == 1 || output_is_change == 1 ? "outPutTableContainerCol" : "outPutTableContainerCol timeType"}>
                    {type == 0 ? output_order_time : ''}
                    {type == 1 ? output_take_time : ''}
                    {type == 2 ? output_pick_time : ''}
                    {type == 3 ? output_pick_end_time : ''}
                    {type == 5 ? output_match_time : ''}
                </Col>
                <Col span={5} className="outPutTableContainerCol">{output_num}</Col>
                <Col span={6} className="outPutTableContainerCol">{customer_name}</Col>
                <Col span={3} className="outPutTableContainerCol">
                    {type == 0 ? output_follow_name : ''}
                    {type == 1 ? output_take_name : ''}
                    {type == 2 || type == 3 ? output_pick_name : ''}
                    {type == 5 ? output_match_name : ''}
                </Col>
                <Col span={2} className="outPutTableContainerCol">{output_type}</Col>
                <Col span={3} className="outPutTableContainerCol">{output_logistics}</Col>
            </Row>
        )
    };
}

class PendingOrderNormal extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {
        const {time, data, type} = this.props;
        return (
            <div>
                <Row className="outPutTime outPutTime3">
                    {time}
                </Row>
                <div>
                    {
                        data.map((item, index) => {
                            return (
                                <PendingOrderItem data={item} key={index} type={type}/>
                            )
                        })
                    }
                </div>
            </div>
        )
    };
}

//待配送
class SendOrderItem extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {
        const {output_is_change, output_is_back, output_match_time, output_num, customer_name, output_match_name, output_type, output_logistics, output_real_package, output_real_single} = this.props.data;
        return (
            <Row
                className={output_is_back == 1 ? 'outPutTableContainer1' : output_is_change == 1 ? "outPutTableContainer2" : "outPutTableContainer"}>
                <Col span={4}
                     className={output_is_back == 1 || output_is_change == 1 ? "outPutTableContainerCol" : "outPutTableContainerCol timeType"}>{output_match_time}</Col>
                <Col span={5} className="outPutTableContainerCol">{output_num}</Col>
                <Col span={5} className="outPutTableContainerCol">{customer_name}</Col>
                <Col span={2} className="outPutTableContainerCol">{output_match_name}</Col>
                <Col span={2} className="outPutTableContainerCol">{output_type}</Col>
                <Col span={3} className="outPutTableContainerCol">{output_logistics}</Col>
                <Col span={1} className="outPutTableContainerCol">{output_real_package}</Col>
                <Col span={1} className="outPutTableContainerCol">{output_real_single}</Col>
                <Col span={1}
                     className="outPutTableContainerCol">{Number(output_real_single) + Number(output_real_package)}</Col>
            </Row>
        )
    };
}

class SendOrderNormal extends Component {
    constructor(props) {
        super(props);
        this.state = {}
    };

    render() {
        const {time, data} = this.props;
        return (
            <div>
                <Row className="outPutTime outPutTime3">
                    {time}
                </Row>
                <div>
                    {
                        data.map((item, index) => {
                            return (
                                <SendOrderItem data={item} key={index}/>
                            )
                        })
                    }
                </div>
            </div>
        )
    };
}

export default Delivery;